package com.ruoyi.project.ums.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.db.ums.domain.UmsFootprint;
import com.ruoyi.db.ums.domain.query.UmsFootprintQueryVo;
import com.ruoyi.project.ums.service.UmsFootprintService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 浏览足迹Controller
 *
 * @author ruoyi
 * @date 2020-04-22
 */
@Api(tags="ums管理：浏览足迹管理")
@RestController
@RequestMapping("/ums/footprint")
public class UmsFootprintController extends BaseController
{
    @Autowired
    private UmsFootprintService umsFootprintService;

    @ApiOperation("查询浏览足迹列表")
    @PreAuthorize("@ss.hasPermi('ums:footprint:list')")
    @GetMapping("/list")
    public TableDataInfo list(UmsFootprintQueryVo umsFootprintQueryVo)
    {
        startPage();
        List<UmsFootprint> list = umsFootprintService.selectUmsFootprintList(umsFootprintQueryVo);
        return getDataTable(list);
    }

    @ApiOperation("导出浏览足迹列表")
    @Log(title = "浏览足迹", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('ums:footprint:export')")
    @GetMapping("/export")
    public AjaxResult export(UmsFootprintQueryVo umsFootprintQueryVo)
    {
        List<UmsFootprint> list = umsFootprintService.selectUmsFootprintList(umsFootprintQueryVo);
        ExcelUtil<UmsFootprint> util = new ExcelUtil<UmsFootprint>(UmsFootprint.class);
        return util.exportExcel(list, "footprint");
    }

    @ApiOperation("获取浏览足迹详细信息")
    @Log(title = "浏览足迹", businessType = BusinessType.OTHER)
    @PreAuthorize("@ss.hasPermi('ums:footprint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(umsFootprintService.selectUmsFootprintById(id));
    }

    @ApiOperation("新增浏览足迹")
    @Log(title = "浏览足迹", businessType = BusinessType.INSERT)
    @PreAuthorize("@ss.hasPermi('ums:footprint:add')")
    @PostMapping
    public AjaxResult add(@RequestBody UmsFootprint umsFootprint)
    {
        return toAjax(umsFootprintService.insertUmsFootprint(umsFootprint));
    }

    @ApiOperation("修改浏览足迹")
    @Log(title = "浏览足迹", businessType = BusinessType.UPDATE)
    @PreAuthorize("@ss.hasPermi('ums:footprint:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody UmsFootprint umsFootprint)
    {
        return toAjax(umsFootprintService.updateUmsFootprint(umsFootprint));
    }

    @ApiOperation("删除浏览足迹")
    @Log(title = "浏览足迹", businessType = BusinessType.DELETE)
    @PreAuthorize("@ss.hasPermi('ums:footprint:remove')")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(umsFootprintService.deleteUmsFootprintByIds(ids));
    }
}
